Fix crashes with completion and composed characters.
authorEli Zaretskii <eliz@gnu.org>
Tue, 23 Aug 2011 08:38:29 +0000 (11:38 +0300)
committerEli Zaretskii <eliz@gnu.org>
Tue, 23 Aug 2011 08:38:29 +0000 (11:38 +0300)
 src/dispnew.c (buffer_posn_from_coords): Use buf_charpos_to_bytepos
 instead of CHAR_TO_BYTE.  Fixes a crash when a completion
 candidate is selected by the mouse, and that candidate has a
 composed character under the mouse.

src/ChangeLog
src/dispnew.c

index 143d50dfeb4551ced748a03084ebd5d420a1aea4..678a9f444fa99c03414d9c5b120bdf32c89a266f 100644 (file)
@@ -1,5 +1,10 @@
 2011-08-23  Eli Zaretskii  <eliz@gnu.org>
 
+       * dispnew.c (buffer_posn_from_coords): Use buf_charpos_to_bytepos
+       instead of CHAR_TO_BYTE.  Fixes a crash when a completion
+       candidate is selected by the mouse, and that candidate has a
+       composed character under the mouse.
+
        * xdisp.c (x_produce_glyphs): Set it->nglyphs to 1.  Fixes pixel
        coordinates reported by pos-visible-in-window-p for a composed
        character in column zero.
index fadfbb2660327778706a0361cd9e260cc6b0af61..e2bcf5d7090def91c821b11f9ff871bdaab0b7a1 100644 (file)
@@ -5307,7 +5307,8 @@ buffer_posn_from_coords (struct window *w, int *x, int *y, struct display_pos *p
       if (STRINGP (it.string))
        BYTEPOS (pos->pos) = string_char_to_byte (string, CHARPOS (pos->pos));
       else
-       BYTEPOS (pos->pos) = CHAR_TO_BYTE (CHARPOS (pos->pos));
+       BYTEPOS (pos->pos) = buf_charpos_to_bytepos (XBUFFER (w->buffer),
+                                                    CHARPOS (pos->pos));
     }
 
 #ifdef HAVE_WINDOW_SYSTEM